﻿using System;
using System.Threading;

namespace Numble
{
    class BYE
    {
        public static Random next = new Random();

        public static void Bye(int n, int time)
        {
            int heigth = n;
            int column = n + 5;
            PrintB(n, heigth, column);

            heigth += n;
            column += 0;
            PrintY(n, heigth, column);

            heigth += n;
            column += 0;
            PrintE(n, heigth, column);

            Console.SetCursorPosition(13, 29);
            Console.WriteLine("NUMBLE BY R A V E N");
            Thread.Sleep(10 * time);
        }
             
        static void PrintB(int n, int heigth, int column)
        {
            string[,] matrix = new string[n, (n - 2)];

            Console.ForegroundColor = ConsoleColor.Green;

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                Console.SetCursorPosition(heigth, column++);

                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    if (col == 0 ||
                        ((row == 0 || row == n / 2 || row == n - 1) && col < matrix.GetLength(1) - 1) ||
                        (col == matrix.GetLength(1) - 1 && row >= 1 && row < n / 2) ||
                        (col == matrix.GetLength(1) - 1 && row > n / 2 && row <= n - 2))
                    {
                        int num = next.Next(0, 10);
                        Console.Write(num);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
            }
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine();
        }
        
        static void PrintY(int size, int heigth, int column)
        {
            string[,] matrix = new string[size, (size - 2)];

            Console.ForegroundColor = ConsoleColor.Yellow;

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                Console.SetCursorPosition(heigth, column++);

                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    if ((col == (size - 2) / 2 && row >= size / 2) || ((row >= 0 && row < size / 2) && (row == col || row + col == size - 3)))//|| (row == n / 2 && col == (n - 2) / 2))
                    {
                        int num = next.Next(0, 10);

                        Console.Write(num);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
            }
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine();
        }

        static void PrintE(int n, int heigth, int column)
        {

            string[,] matrix = new string[n, (n - 2)];
            Console.ForegroundColor = ConsoleColor.Red;

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                Console.SetCursorPosition(heigth, column++);

                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    if (row == 0 || row == n / 2 || row == n - 1)
                    {
                        int num = next.Next(0, 10);
                        Console.Write(num);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine();
        }
    }
}